﻿package com.myp.mystage
{
    import flash.display.*;

    public class MyStage extends Object
    {
        private static const MIN_HEIGHT:uint = 550;
        private static var instance:MyStage;
        private static const MIN_WIDTH:uint = 1000;
        private static var _stage:Stage;

        public function MyStage()
        {
            this.prepare(_stage);
            return;
        }// end function

        public function relCenterX(param1:Number) : Number
        {
            return (this.width - param1) * 0.5;
        }// end function

        public function get centerX() : Number
        {
            return this.width * 0.5;
        }// end function

        public function get centerY() : Number
        {
            return this.height * 0.5;
        }// end function

        public function get width() : Number
        {
            if (!_stage)
            {
                return MIN_WIDTH;
            }// end if
            return _stage.stageWidth > MIN_WIDTH ? (_stage.stageWidth) : (MIN_WIDTH);
        }// end function

        public function get height() : Number
        {
            if (!_stage)
            {
                return MIN_HEIGHT;
            }// end if
            return _stage.stageHeight > MIN_HEIGHT ? (_stage.stageHeight) : (MIN_HEIGHT);
        }// end function

        public function relCenterY(param1:Number) : Number
        {
            return (this.height - param1) * 0.5;
        }// end function

        public function get stage() : Stage
        {
            return _stage;
        }// end function

        public function prepare(param1:Stage) : void
        {
            param1.align = StageAlign.TOP_LEFT;
            param1.scaleMode = StageScaleMode.NO_SCALE;
            return;
        }// end function

        public static function getInstance(param1:Stage = null) : MyStage
        {
            _stage = _stage ? (_stage) : (param1);
            instance = instance ? (instance) : (new MyStage);
            return instance;
        }// end function

    }
}
